{layout name="public/tab_layout" /}
<div class="layui-container">  
    <div class="layui-row">
    <div class="layui-col-xs10 layui-col-xs-offset1">
    
            <form class="layui-form" action="">
                    <div class="layui-form-item">
                            <label class="layui-form-label">分类</label>
                            <div class="layui-input-inline">
                                <select name="cid"  lay-search="">
                                    {volist name="categoryarr" id="vo"}  
                                    <option value="{$vo.id}" {if condition="$vo.id == $info.cid"}selected=""{/if}>{$vo.name}</option>
                                    {/volist}
                                  </select>
                            </div>
                    </div>
                    <div class="layui-form-item">
                      <label class="layui-form-label">物料名称</label>
                      <div class="layui-input-inline">
                        <input type="text" name="name"autocomplete="off" placeholder="请输入名称" class="layui-input" value="{$info.name}">
                      </div>
                    </div>
                    <div class="layui-form-item">
                            <label class="layui-form-label">型号</label>
                            <div class="layui-input-inline">
                              <input type="text" name="model" autocomplete="off" class="layui-input"  value="{$info.model}">
                            </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">位置</label>
                        <div class="layui-input-inline" style="width: 55px;">
                            <select name="cno"  lay-search="">
                                {volist name="strarr" id="vo"}  
                                <option value="{$vo}" {if condition="$vo == $info.cno"}selected=""{/if}>{$vo}</option>
                                {/volist}
                              </select>                       
                        </div>
                        <div class="layui-input-inline" style="width: 65px;">
                            <select name="boxno"  lay-search="">
                                {volist name="numarr" id="vo"}  
                                <option value="{$vo}" {if condition="$vo == $info.boxno"}selected=""{/if}>{$vo}</option>
                                {/volist}
                              </select>                       
                        </div>
                        <div class="layui-input-inline" style="width: 65px;">
                            <select name="bagno"  lay-search="">
                                {volist name="numarr" id="vo"}  
                                <option value="{$vo}" {if condition="$vo == $info.bagno"}selected=""{/if}>{$vo}</option>
                                {/volist}
                              </select>                       
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">数量</label>
                        <div class="layui-input-inline">
                          <input type="text" name="num" autocomplete="off" class="layui-input"  value="{$info.num}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">参考价格</label>
                        <div class="layui-input-inline">
                          <input type="text" name="price" autocomplete="off" class="layui-input"  value="{$info.price}">
                        </div>
                    </div>
                    
                    <div class="layui-form-item">
                            <label class="layui-form-label">描述</label>
                            <div class="layui-input-inline">
                              <input type="text" name="note"  autocomplete="off"class="layui-input" value="{$info.note}">
                            </div>
                    </div>
    
            </form>
            
    </div>
    </div>
    
    <div class="layui-row">
            <div class="layui-col-xs4 layui-col-xs-offset4">
    
                    <div class="layui-btn-group">
                        <button class="layui-btn layui-btn-normal btn_save">保存</button>
                    </div>
            </div>
    </div>      
    
    </div>
    
    <script>
    layui.use('form', function(){
        var form = layui.form;
    });
    //绑定按钮
    $(function(){
        $('.btn_save').on('click',function(){
            //读取输入框的值
            var value = {
                name: $("input[name='name']").val(),
                cid: $("select[name='cid']").val(),
                cno: $("select[name='cno']").val(),
                boxno: $("select[name='boxno']").val(),
                bagno: $("select[name='bagno']").val(),
                num: $("input[name='num']").val(),
                price: $("input[name='price']").val(),
                note: $("input[name='note']").val(),
                model: $("input[name='model']").val(),
                pn: {$pn},
            };
            $.post("{:url('Warehouse/Item/save')}", value,
                function(ret) {
                var status = "1" == ret.status ? "success": "error";
                if(status == "success"){
                    layer.msg('操作成功！'); //2秒后自动关闭，-1代表不显示图标
                    setTimeout("parent.location.reload();",1000);//1秒后刷新父类
                }
            },"json")
        })
    
    })
    </script>